package com.video.web.controller.video;

import com.video.video.domain.GoodDownloadRecord;
import com.video.video.service.IGoodDownloadRecordService;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.video.common.annotation.Log;
import com.video.common.core.controller.BaseController;
import com.video.common.core.domain.AjaxResult;
import com.video.common.enums.BusinessType;
import com.video.common.utils.poi.ExcelUtil;
import com.video.common.core.page.TableDataInfo;

/**
 * vip下载记录Controller
 *
 * @author ruoyi
 * @date 2023-03-16
 */
@RestController
@RequestMapping("/video/download")
public class GoodDownloadRecordController extends BaseController
{
    @Autowired
    private IGoodDownloadRecordService goodDownloadRecordService;

    /**
     * 查询vip下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('video:download:list')")
    @GetMapping("/list")
    public TableDataInfo list(GoodDownloadRecord goodDownloadRecord)
    {
        startPage();
        List<GoodDownloadRecord> list = goodDownloadRecordService.selectGoodDownloadRecordList(goodDownloadRecord);
        return getDataTable(list);
    }

    /**
     * 导出vip下载记录列表
     */
    @PreAuthorize("@ss.hasPermi('video:download:export')")
    @Log(title = "vip下载记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GoodDownloadRecord goodDownloadRecord)
    {
        List<GoodDownloadRecord> list = goodDownloadRecordService.selectGoodDownloadRecordList(goodDownloadRecord);
        ExcelUtil<GoodDownloadRecord> util = new ExcelUtil<GoodDownloadRecord>(GoodDownloadRecord.class);
        util.exportExcel(response, list, "vip下载记录数据");
    }

    /**
     * 获取vip下载记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:download:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(goodDownloadRecordService.selectGoodDownloadRecordById(id));
    }

    /**
     * 新增vip下载记录
     */
    @PreAuthorize("@ss.hasPermi('video:download:add')")
    @Log(title = "vip下载记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoodDownloadRecord goodDownloadRecord)
    {
        return toAjax(goodDownloadRecordService.insertGoodDownloadRecord(goodDownloadRecord));
    }

    /**
     * 修改vip下载记录
     */
    @PreAuthorize("@ss.hasPermi('video:download:edit')")
    @Log(title = "vip下载记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoodDownloadRecord goodDownloadRecord)
    {
        return toAjax(goodDownloadRecordService.updateGoodDownloadRecord(goodDownloadRecord));
    }

    /**
     * 删除vip下载记录
     */
    @PreAuthorize("@ss.hasPermi('video:download:remove')")
    @Log(title = "vip下载记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(goodDownloadRecordService.deleteGoodDownloadRecordByIds(ids));
    }
}
